package com.fimuz.mqmeet.api.loginuser.control;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.Application;
import com.fimuz.mqmeet.api.loginuser.service.LoginuserService;
import com.fimuz.mqmeet.api.loginuser.service.model.ActiveUserEmailSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ActiveUserEmailSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ChangePasswordSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ChangePasswordSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.CreateOrUpdateSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.CreateOrUpdateSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.CreateSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.CreateSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.DeleteSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.DeleteSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ExistsEmailSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ExistsEmailSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.GetSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.GetSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ListSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.ListSrModel;
import com.fimuz.mqmeet.api.loginuser.service.model.UpdateSpModel;
import com.fimuz.mqmeet.api.loginuser.service.model.UpdateSrModel;
import com.fosun.spr.core.base.CoBaseControl;
import com.fosun.spr.core.utils.SessionUtils;

@Controller
public class LoginuserControl extends CoBaseControl {
	//@Autowired
	@Resource
	private LoginuserService loginuserService;

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/list
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */
	@RequestMapping(value = "/api/loginuser/list", method = RequestMethod.GET)
	public ListSrModel list(HttpServletRequest request, ListSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		ListSrModel srModel = loginuserService.list(spModel);
		return srModel;
	}

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/existsEmail
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */
	@RequestMapping(value = "/api/loginuser/existsEmail", method = RequestMethod.GET)
	public ExistsEmailSrModel existsEmail(HttpServletRequest request,
			ExistsEmailSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		ExistsEmailSrModel srModel = loginuserService.existsEmail(spModel);
		return srModel;
	}

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/delete { "id":"" }
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */
	@RequestMapping(value = "/api/loginuser/delete", method = RequestMethod.POST)
	public DeleteSrModel delete(HttpServletRequest request,
			@RequestBody DeleteSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		DeleteSrModel srModel = loginuserService.delete(spModel);
		return srModel;
	}

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/createOrUpdate {
	 * "id":"", "loginPassword":"", "memo":"", "roleUuids":[], "userEmail":"",
	 * "userName":"", "userPhone":"" }
	 * @deprecated
	 * @param request
	 * @param spModel
	 * @return
	 */
	@RequestMapping(value = "/api/loginuser/createOrUpdate", method = RequestMethod.POST)
	public CreateOrUpdateSrModel createOrUpdate(HttpServletRequest request,
			@RequestBody CreateOrUpdateSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		CreateOrUpdateSrModel srModel = loginuserService
				.createOrUpdate(spModel);
		return srModel;
	}

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/get
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */
	@RequestMapping(value = "/api/loginuser/get", method = RequestMethod.GET)
	public GetSrModel get(HttpServletRequest request, GetSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		GetSrModel srModel = loginuserService.get(spModel);
		return srModel;
	}

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/changePassword
{
	"newPassword":"",
	"oldPassword":""
}

	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/loginuser/changePassword",method = RequestMethod.POST)
	public ChangePasswordSrModel changePassword(HttpServletRequest request,@RequestBody ChangePasswordSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		ChangePasswordSrModel srModel = loginuserService.changePassword(spModel);
		return srModel;
	}
	
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/create
	 * {"":"","":""}
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/loginuser/create",method = RequestMethod.POST)
	public CreateSrModel create(HttpServletRequest request,@RequestBody CreateSpModel spModel) {
		//SessionUtils.fillSpModel(request, spModel);
		CreateSrModel srModel = loginuserService.create(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/update
	 * {"":"","":""}
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/loginuser/update",method = RequestMethod.POST)
	public UpdateSrModel update(HttpServletRequest request,@RequestBody UpdateSpModel spModel) {
		//SessionUtils.fillSpModel(request, spModel);
		UpdateSrModel srModel = loginuserService.update(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/loginuser/activeUserEmail
	 * {"":"","":""}
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/loginuser/activeUserEmail",method = RequestMethod.POST)
	public ActiveUserEmailSrModel activeUserEmail(HttpServletRequest request,@RequestBody ActiveUserEmailSpModel spModel) {
		//SessionUtils.fillSpModel(request, spModel);
		ActiveUserEmailSrModel srModel = loginuserService.activeUserEmail(spModel);
		return srModel;
	}
		

//	// 生成成json的代码
//	public static void main(String[] args) throws Exception {
//		debugPrintJsonSpModel(new DeleteSpModel());
//		debugPrintJsonSpModel(new CreateOrUpdateSpModel());
//		debugPrintJsonSpModel(new ChangePasswordSpModel());
//		debugPrintJsonSpModel(new CreateSpModel());
//		debugPrintJsonSpModel(new UpdateSpModel());
//		debugPrintJsonSpModel(new CreateSpModel());
//		debugPrintJsonSpModel(new UpdateSpModel());
//		debugPrintJsonSpModel(new ActiveUserEmailSpModel());		
//	}
	
//    public static void main(String[] args) {
//        SpringApplication.run(LoginuserControl.class, args);
//    }

}
